import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CustomScrollViewTestRoute extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _CustomScrollViewTestRouteState();
  }
}

class _CustomScrollViewTestRouteState extends State<CustomScrollViewTestRoute> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Material(
      child: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            pinned: true,
            floating: true,
            expandedHeight: 250,
//            flexibleSpace: FlexibleSpaceBar(
//              title: Text('测试cesium'),
//              background: Image.asset(
//                'dsc03576.jpg',
//                fit: BoxFit.fitHeight,
//              ),
//            ),
          flexibleSpace: Image.asset('index.jpg',fit: BoxFit.cover,),
          ),
          SliverPadding(
            padding: EdgeInsets.all(8.0),
            sliver: SliverGrid(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  childAspectRatio: 4,
                  mainAxisSpacing: 2.0,
                  crossAxisSpacing: 2.0),
              delegate: SliverChildBuilderDelegate((context, position) {
                return Container(
                  alignment: Alignment.center,
                  color: Colors.cyan[100 * (position % 9)],
                  child: new Text('grid item $position'),
                );
              }, childCount: 20),
            ),
          ),
          SliverList(
            delegate: SliverChildBuilderDelegate((context, index) {
              return Container(
                alignment: Alignment.center,
                padding: EdgeInsets.all(20),
                color: Colors.lightBlue[100 * (index % 9)],
                child: new Text('list item $index'),
              );
            }, childCount: 20),
          ),
        ],
      ),
    );
  }
}
